package com.shkco.xbjcc.service.impl;

import com.shkco.xbjcc.domain.User;
import com.shkco.xbjcc.domain.UserIntegral;
import com.shkco.xbjcc.domain.UserInviteCode;
import com.shkco.xbjcc.mapper.UserInviteCodeMapper;
import com.shkco.xbjcc.mapper.UserMapper;
import com.shkco.xbjcc.service.IUserInviteCodeService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author whale
 * @since 2022-10-05
 */
@Service
public class  UserInviteCodeServiceImpl extends ServiceImpl<UserInviteCodeMapper, UserInviteCode> implements IUserInviteCodeService {

    @Autowired
    private UserMapper userMapper;

    @Autowired
    private UserInviteCodeMapper userInviteCodeMapper;

    @Override
    public UserInviteCode getInviteCode(String username) {
        User user = userMapper.findByMobile(username);
        UserInviteCode userInviteCode = userInviteCodeMapper.findByUserId(user.getId());
        return userInviteCode;
    }

    @Override
    public UserInviteCode findByCode(String inviteCode) {
        return userInviteCodeMapper.findByCode(inviteCode);
    }
}
